/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.amse.grigory.dchess.view;

import java.awt.FlowLayout;
import java.awt.Font;
import java.util.ArrayList;
import java.util.Scanner;
import javax.swing.*;
import org.amse.grigory.dchess.dchess.DChess;

/**
 *
 * @author grigory
 */
public class AboutDialog extends JDialog {

    private static ClassLoader myClassLoader = DChess.class.getClassLoader();

    public AboutDialog(JFrame frame) {
        super(frame, true);
        setLocation(frame.getLocation().x + 100, frame.getLocation().y + 100);
        fillDialog();
        setSize(250, 500);
        setResizable(false);
        setVisible(true);
    }

    private void fillDialog() {
        Scanner scanner = new Scanner(myClassLoader.getResourceAsStream("org/amse/grigory/dchess/dchess/about"));
        ArrayList<JLabel> list = new ArrayList<JLabel>();
        JLabel label = new JLabel("DChess");
        label.setFont(new Font("Serif", Font.BOLD, 20));
        while (scanner.hasNextLine()) {
            list.add(new JLabel(scanner.nextLine()));
        }
        Icon icon = new ImageIcon(myClassLoader.getResource("data/img/icons/image.jpeg"));
        JLabel iconLabel = new JLabel(icon);
        JPanel mainP = new JPanel();
        mainP.setLayout(new FlowLayout());
        JPanel nameP = new JPanel();
        JPanel textP = new JPanel();
        textP.setLayout(new BoxLayout(textP, BoxLayout.Y_AXIS));
        nameP.add(label);
        textP.add(iconLabel);
        for (int i = 0; i < list.size(); i++) {
            textP.add(list.get(i));
        }
        mainP.add(nameP);
        mainP.add(textP);
        getContentPane().add(mainP);
    }
}
